# 使用支持 toolchain 指令的 Go 版本
FROM golang:1.22-alpine AS builder

# 安装编译依赖
RUN apk add --no-cache git gcc musl-dev

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=1 GOOS=linux go build -a -o app .

# 运行时镜像
FROM alpine:3.16
RUN apk add --no-cache ca-certificates tzdata libc6-compat
WORKDIR /app
COPY --from=builder /app/app .
COPY static/ ./static/
EXPOSE 8080
CMD ["./app"]